package com.mr.model;

import java.sql.Timestamp;

import com.mr.util.DateUtil;
import com.mr.util.DesUtils;

public class Member extends BaseObject{
	private static final long serialVersionUID = 5314131085323556747L;
	public static final String MEMBERTYPE_USER = "user";
	public static final String MEMBERTYPE_SHOP = "shop";
	public static final String MEMBERTYPE_PROXY = "proxy";
	public static final String MEMBERTYPE_COMPAMNY = "company";
	private Long id;
	private String membername;
	private String password;
	private String pwd;
	private String membertype;
	private Timestamp addtime;
	private Long parentid;
	public Long getParentid() {
		return parentid;
	}
	public void setParentid(Long parentid) {
		this.parentid = parentid;
	}
	public Member() {
		this.addtime = DateUtil.getCurTimestamp();
	}
	public Member(String membername, String password){
		this();
		this.membername = membername;
		this.password = password;
	}
	public Member(String membername, String password, String pwd, String membertype, BaseInfo base){
		this();
		this.membername = membername;
		this.password = password;
		this.pwd = pwd;
		this.membertype = membertype;
		this.parentid = base.getId();
	}
	public Member(String membername, String password, Long parentid){
		this(membername, password);
		this.parentid = parentid;
	}
	public String getRealpwd(){
		return DesUtils.decrypt(pwd);
	}
	public String getEnId(){
		return DesUtils.encrypt(this.id+"");
	}
	public Timestamp getAddtime() {
		return addtime;
	}
	public void setAddtime(Timestamp addtime) {
		this.addtime = addtime;
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getMembername() {
		return membername;
	}
	public void setMembername(String membername) {
		this.membername = membername;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getEncode() {
		try {
			return DesUtils.encrypt(this.id+"");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "";
	}
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (!(o instanceof Member))
			return false;

		final Member temp = (Member) o;

		return !(this.getId() != null ? !(this.getId().equals(temp.getId()))
				: (temp.getId() != null));

	}

	public int hashCode() {
		return (this.getId() != null ? this.getId().hashCode() : 0);
	}
	public String getMembertype() {
		return membertype;
	}
	public void setMembertype(String membertype) {
		this.membertype = membertype;
	}
	public String getPwd() {
		return pwd;
	}
	public void setPwd(String pwd) {
		this.pwd = pwd;
	}
}
